package com.zzq.job;

import com.zzq.constant.RedisConstant;
import com.zzq.utils.QiniuUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.Set;

/**
 * 幼儿猿大班
 * 2021/7/24
 */
@Component
public class MyJob {

    @Autowired
    private JedisPool jedisPool;

    public void cleanImg(){
        Jedis jedis = jedisPool.getResource();
        Set<String> sdiff = jedis.sdiff(RedisConstant.SETMEAL_PIC_RESOURCES, RedisConstant.SETMEAL_PIC_DB_RESOURCES);
        for (String s : sdiff) {
            jedis.srem(RedisConstant.SETMEAL_PIC_RESOURCES,s);
            QiniuUtils.deleteFileFromQiniu(s);
        }
    }
}
